package mya_dc.shared_classes;

import java.io.Serializable;

/**
 * a class thats saves the compilation flags that were chosen by
 * the client.
 *
 * @author      Adam Levi
 * <br>			MYA
 */
public class CompilationFlags implements Serializable
{
	private static final long serialVersionUID = 2663490214117259022L;
	public static String defaultFileName = "output.exe";
	
	/**
	 * default constructor
	 */
	public CompilationFlags()
	{
		basicOpt = BasicOptimization.NONE;
		machineDepOpt = MachimeDepOptimization.GENERIC;
		outputFileName = CompilationFlags.defaultFileName;
	}
	
	public enum BasicOptimization 
	{
		NONE,
		O1,
		O2,
		O3_MAX
	}
	public enum MachimeDepOptimization 
	{
		GENERIC,
		PENTIUM4M,
		ATHLON_K8
	}
	
	@Override public String toString()
	{
		String retString = "";
		switch(machineDepOpt)
		{
		case GENERIC: break;
		case PENTIUM4M: retString += "-mtune=k8 "; break;
		case ATHLON_K8: retString += "-mtune=pentium4 "; break;
		}
		switch(basicOpt)
		{
		case NONE: break;
		case O1: retString += "-O1"; break;
		case O2: retString += "-O2"; break;
		case O3_MAX: retString += "-O3"; break;
		}
		return retString;
	}
	
	@Override public boolean equals(Object obj)
	{
		if (obj instanceof CompilationFlags) {
			CompilationFlags flags = (CompilationFlags) obj;
			if (	flags.basicOpt == this.basicOpt &&
					flags.machineDepOpt == this.machineDepOpt &&
					outputFileName.equals(this.outputFileName))
			{
				return true;
			}
			return false;
		}
		return false;
	}
	@Override public int hashCode()
	{
		return outputFileName.hashCode();
	}
	
	//variables
	public BasicOptimization 		basicOpt;
	public MachimeDepOptimization 	machineDepOpt;
	public String					outputFileName;
}
